package com.netease.videoLoaderDemo;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView;


import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatSpinner;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import com.netease.neliveplayer.playerkit.videoLoader.VideoLoaderImpl;
import com.netease.videoSlidingKit.R;


public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";
    private AppCompatSpinner mSpinner;
    private AppCompatSpinner mAddressSpinner;

    private TextView tvspinner;
    private TextView tvAddressSpinner;
    private int mode;
    public static int videoSource;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initUi();
    }

    private void initUi() {
        findViewById(R.id.btEnter).setOnClickListener(v -> {
            Intent intent = new Intent(this, RoomListActivity.class);
            intent.putExtra("mode", mode);
            startActivity(intent);

        });
        mSpinner = findViewById(R.id.spSliceMode);
        tvspinner = findViewById(R.id.tvSliceModeShow);
        mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                mode = position;
                tvspinner.setText(mSpinner.getSelectedItem().toString());
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

        mAddressSpinner = findViewById(R.id.spVideoSource);
        tvAddressSpinner = findViewById(R.id.tvVideoSource);
        mAddressSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                videoSource = position;
                VideoLoaderImpl.getInstance().changeVideoSource(position, true);
                tvAddressSpinner.setText(mAddressSpinner.getSelectedItem().toString());
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
    }


}